<?php
session_start();
?>
<!--/*验证码的session开始，如果不放在前面，有的服务器会出现警告*/-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script type="text/javascript" src="../front/js/jquery-1.10.2.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><?php include '../controlbase/coresection/title.php'; ?></title>
<style type="text/css">
    html{ width: 100%; height: 100%;}
    body{
        background: #F3F3F3 url("images/logo.jpg") no-repeat center top;
        padding: 0; margin: 0; position: relative; width: 100%; height: 100%;;
    }
    #loginform{ position: absolute; top: 50%; left: 50%; margin: -205px 0 0 -213px; text-align: center;}
    #loginform ul{background: #FFF; width:306px;width: 426px\9; height: 345px; height:415px\9; box-shadow: #ccc 3px 3px 10px; filter: progid:DXImageTransform.Microsoft.Shadow(color='#cccccc', Direction=125, Strength=5); margin: 0; padding: 65px 60px 0; list-style: none; overflow: hidden;}
    #loginform ul li{ border: #CCC 1px solid;border-bottom:#ccc 2px solid\9;border-right:#ccc 2px solid;border-radius: 5px;behavior: url(PIE.htc)\9;  height:54px\9;padding: 10px 25px;padding-bottom: 0px\9; overflow: hidden;overflow: visible\9; margin-bottom: 25px;}
    #loginform ul li label{ height: 34px; width: 45px; float: left; border-right:#CCC 1px solid; }
    #loginform ul li .ico_1{ background: url("images/input_icon1.jpg") no-repeat left center;}
    #loginform ul li .ico_2{ background: url("images/input_icon2.jpg") no-repeat left center;}
    #loginform ul li .ico_3{ background: url("images/input_icon3.jpg") no-repeat left center;}
    #loginform ul li input{ border: none; height: 34px;margin-top: 0px\9; padding: 0 5px;padding-top: 10px\9; margin-left: 15px; width: 170px; float: left; color: #999;}
    #loginform ul li #submit{ background: #84b8f3; color: #FFF; width: 100%; margin: 0; padding: 0; height: 50px; font-size: 1.2em; font-family: "microsoft yahei"; cursor: pointer;}
</style>
</head>

<body>

<?

if(!isset($_REQUEST['username']) or $_REQUEST['username']=='')
{
	$_REQUEST['username']='';
	$_REQUEST['userpass']='';
}
?>


<form id="loginform" name="loginform" method="post" action="" enctype="multipart/form-data" >
    <ul>
        <li>
            <label class="ico_1"></label>
            <input name="username" type="text" class="input" id="username" alt="账号" value="<? echo $_REQUEST['username'] ?>" />
        </li>
        <li>
            <label class="ico_2"></label>
            <input name="userpass" type="password"  class="input" id="userpass" alt=""  value="<? echo $_REQUEST['userpass'] ?>" placeholder="密码"/>

        </li>
        <li style="width: 146px;width: 197px\9; float: left;">
            <label class="ico_3"></label>
            <input type="text" name="code" id="code" style="width: 73px;" alt="验证码">
        </li>
        <img src="../application/verify/z_imgcode.php" onclick='this.src="../application/verify/z_imgcode.php?"+Math.random();' style="cursor:pointer; border:1px solid #CC9900; width: 95px; float: left; margin: 7px 0 0 10px;position: absolute\9;right: 60px\9;top:225px\9;" />
        <?php
        if(isset($_REQUEST['code'])){
            if($_REQUEST['code'] == strtolower($_SESSION['yzm'])){
                echo "
		<script type='text/javascript'>
		document.getElementById('loginform').action = 'logincheck.php';
        document.getElementById('loginform').submit();
		</script>";
            }else{
                echo '<script type="text/javascript"> alert("请输入正确的验证码！");</script>';
            }
        }
        ?>
        <li style="clear: both; border: none; padding: 0;">
            <input type="submit" name="submit" id='submit' value="登　陆" />
        </li>
    </ul>
    <img src="images/logo_bottom.jpg" alt="圆点设计" style="margin: 30px auto 20px;"/>
</form>

<script type="text/javascript">
    (function($) {
        /**
         * 没有开花的树
         * 2012/11/28 15:12
         */

        var placeholderfriend = {
            focus: function(s) {
                s = $(s).hide().prev().show().focus();
                var idValue = s.attr("id");
                if (idValue) {
                    s.attr("id", idValue.replace("placeholderfriend", ""));
                }
                var clsValue = s.attr("class");
                if (clsValue) {
                    s.attr("class", clsValue.replace("placeholderfriend", ""));
                }
            }
        }

        //判断是否支持placeholder
        function isPlaceholer() {
            var input = document.createElement('input');
            return "placeholder" in input;
        }
        //不支持的代码
        if (!isPlaceholer()) {
            $(function() {

                var form = $(this);

                //遍历所有文本框，添加placeholder模拟事件
                var elements = form.find("input[type='text'][placeholder]");
                elements.each(function() {
                    var s = $(this);
                    var pValue = s.attr("placeholder");
                    var sValue = s.val();
                    if (pValue) {
                        if (sValue == '') {
                            s.val(pValue);
                        }
                    }
                });

                elements.focus(function() {
                    var s = $(this);
                    var pValue = s.attr("placeholder");
                    var sValue = s.val();
                    if (sValue && pValue) {
                        if (sValue == pValue) {
                            s.val('');
                        }
                    }
                });

                elements.blur(function() {
                    var s = $(this);
                    var pValue = s.attr("placeholder");
                    var sValue = s.val();
                    if (!sValue) {
                        s.val(pValue);
                    }
                });

                //遍历所有密码框，添加placeholder模拟事件
                var elementsPass = form.find("input[type='password'][placeholder]");
                elementsPass.each(function(i) {
                    var s = $(this);
                    var pValue = s.attr("placeholder");
                    var sValue = s.val();
                    if (pValue) {
                        if (sValue == '') {
                            //DOM不支持type的修改，需要复制密码框属性，生成新的DOM
                            var html = this.outerHTML || "";
                            html = html.replace(/\s*type=(['"])?password\1/gi, " type=text placeholderfriend")
                                .replace(/\s*(?:value|on[a-z]+|name)(=(['"])?\S*\1)?/gi, " ")
                                .replace(/\s*placeholderfriend/, " placeholderfriend value='" + pValue
                                + "' " + "onfocus='placeholderfriendfocus(this);' ");
                            var idValue = s.attr("id");
                            if (idValue) {
                                s.attr("id", idValue + "placeholderfriend");
                            }
                            var clsValue = s.attr("class");
                            if (clsValue) {
                                s.attr("class", clsValue + "placeholderfriend");
                            }
                            s.hide();
                            s.after(html);
                        }
                    }
                });

                elementsPass.blur(function() {
                    var s = $(this);
                    var sValue = s.val();
                    if (sValue == '') {
                        var idValue = s.attr("id");
                        if (idValue) {
                            s.attr("id", idValue + "placeholderfriend");
                        }
                        var clsValue = s.attr("class");
                        if (clsValue) {
                            s.attr("class", clsValue + "placeholderfriend");
                        }
                        s.hide().next().show();
                    }
                });

            });
        }
        window.placeholderfriendfocus = placeholderfriend.focus;
    })(jQuery);


</script>

<script language="javascript" type="text/javascript">

    window.onload = function(){


        function textInputFn(name){
            var o =document.getElementById(name);
            o.setAttribute("valueCache",o.value);

            //失去焦点的时候
            o.onblur = function(){
                if(o.value=="") {
                    document.getElementById(name).setAttribute("placeholder","密码");
                    o.valueCache="";
                    o.value=o.alt;

                } else {
                    o.valueCache=o.value;
                }
            };

            //获得焦点的时候
            o.onfocus = function(){
                document.getElementById(name).setAttribute("placeholder","");
                o.value=o.valueCache;
                var e = event.srcElement;
                var r =e.createTextRange();
                r.moveStart('character',e.value.length);
                r.collapse(true);
                r.select();


            };
            o.onblur();
        }



        textInputFn("username");
        textInputFn("userpass");
        textInputFn("code");

    }
</script>
</body>
</html>